﻿using Game.FlowField.Aspect;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;

namespace Game.FlowField.Burst
{
    [BurstCompile]
    public partial struct UnitEntityUpdateJob : IJobEntity
    {
        public EntityCommandBuffer.ParallelWriter ECB;
        public NativeArray<Unit> Units;

        void Execute([ChunkIndexInQuery] int chunkIndex, ref UnitAspect unitAspect)
        {
            var unitIndex = unitAspect.UnitComponentData.ValueRW.UnitIndex;
            if(unitIndex >=0 && unitIndex < Units.Length)
            {
                var unit = Units[unitIndex];
                //unitAspect.Position = new float3(unit.CurrentPosition, 0f);
            }
        }
    }
}
